package org.littlesun.management.ui.child;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.wb.swt.SWTResourceManager;

import swing2swt.layout.BorderLayout;

public class EditChildDialog extends Dialog {

	protected Object result;
	protected Shell shell;

	/**
	 * Create the dialog.
	 * @param parent
	 * @param style
	 */
	public EditChildDialog(Shell parent, int style) {
		super(parent, style);
	}

	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shell = new Shell(getParent(), getStyle());
		shell.setSize(450, 300);
		shell.setLayout(new BorderLayout(0, 0));

	    Composite topArea = new Composite(shell, SWT.NO_FOCUS);
	    topArea.setBackground(SWTResourceManager.getColor(255, 255, 255));
	    topArea.setLayoutData(BorderLayout.NORTH);
	    topArea.setLayout(new FormLayout());

	    Label descriptionLabel = new Label(topArea, SWT.PUSH);
	    descriptionLabel.setBackground(SWTResourceManager.getColor(255, 255, 255));
	    FormData fd_descriptionLabel = new FormData();
	    fd_descriptionLabel.top = new FormAttachment(0, 30);
	    fd_descriptionLabel.bottom = new FormAttachment(100, -10);
	    fd_descriptionLabel.left = new FormAttachment(0, 10);
	    descriptionLabel.setLayoutData(fd_descriptionLabel);
	    descriptionLabel.setFont(SWTResourceManager.getFont("Microsoft JhengHei UI", 12, SWT.NORMAL));
	    descriptionLabel.setText("\u6AA2\u8996");
	    
	    
	}

}
